package com.jiyun.home.service.impl;

import com.jiyun.common.pojo.home.Special;
import com.jiyun.home.mapper.SpecialMapper;
import com.jiyun.home.service.SpecialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@Transactional
public class SpecialServiceImpl implements SpecialService {
    @Autowired
    SpecialMapper specialMapper;
    /**
     * 获取所有特惠信息
     *
     * @return 特惠信息列表
     */
    @Override
    public List<Special> findSpecialAll() {
        List<Special> specialList = specialMapper.findSpecialAll();
        return specialList;
    }

    /**
     * 根据ID获取特惠信息
     *
     * @param id 特惠信息的ID
     * @return 特惠信息对象
     */
    @Override
    public Special findSpecialOne(Integer id) {
        return specialMapper.findSpecialOne(id);
    }

    @Override
    public List<Special> findProductList(List<Integer> list) {
        List<Special> productList = list.stream().map(id -> specialMapper.findSpecialOne(id)).toList();
        return productList;
    }
}
